home *** CD-ROM | disk | FTP | other *** search
-
- Intelligent Get_Key function for Personal Pascal
-
- Written by Keith Ledbetter 6-Sept-87
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-
- This Get_Key routine is a very handy routine for those of you who write TOS
- programs with Personal Pascal. Have you ever been overwhelmed by all of the
- various keypresses that can be generated with an Atari ST keyboard? Not to
- mention the fact that if you do want to process any Function keys, then you
- have to read the keypress as a Long_Integer and go from there.
-
-
- This Get_Key routine solves this problem by returning everything as a CHAR
- value. What it does is to return values in the high range (that couldn't
- be entered from the keyboard anyway). This makes it very simple for you to
- process function keys from within your pascal program.
-
-
- Any function key pressed will be returned as a CHAR value ranging from
- 201 through 235. Any 'normal' (ie: 'a', 'Z', etc) will be returned normally.
- From your pascal program, just declare Get_Key as follows:
-
-
- Function Get_Key: Char; External;
-
-
- Then, just LINK getkey.o along with your program's .o file.
-
-
- Get_Key will return any non-function key just as normal. The SPECIAL values
- returned from Get_Key are as follows:
-
-
- Keypress Value
- -------- -----
- F1 - F10 201 - 210
- F11 - F20 211 - 220 ( these are SHIFT F1 - F10 )
- left arrow 221
- right arrow 222
- ^left arrow 223
- ^right arrow 224
- delete 225
- insert 226
- undo 227
- help 228
- clear/home 229
- shift clear 230
- shift insert 231
- shift left arrow 232
- shift up arrow 233
- shift right arrow 234
- shift down arrow 235
-
-
- This makes it very easy to process keypresses with the following type
- of code:
-
- Var Ch: Char;
-
- Begin
- Repeat
- Ch := Get_Key;
- Case Ord (Ch) of
- 201: Writeln ('You hit the F1 key!');
- 228: Writeln ('You hit the HELP key!');
- Else: Writeln ('You hit the ', Ch, ' key');
- End;
- Until whatever;
-
-
-
- The assembler source code to GET_KEY is included in the ARC file, but you DO
- NOT need to do anything with it. It's just there in case someone would like
- to add more keys to the table. If you do, just make SURE that you keep the
- '0,0' entry at the end of the table.
-
-
- Keith Ledbetter
- CIS #76701,124
-